package com.ztesoft.iom.adapter.server.controller;

import com.ztesoft.iom.adapter.server.result.IomResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by kangkang on 2018/4/9.
 */

@CrossOrigin
@RestController
@RequestMapping(value = "/api")
public class IomRestController {

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping(value = "/v1/iom-adapter/indexTest",method = RequestMethod.POST)
    public IomResult indexTest(HttpServletRequest request,@RequestBody Map params){
//        restTemplate.getForObject()
        return  new IomResult(params);
    }

    @RequestMapping(value = "/v1/iom-adapter/index/{serviceCode}",method = RequestMethod.POST)
    public IomResult index(HttpServletRequest request, @RequestBody Map params, @PathVariable String serviceCode){
//        restTemplate.getForObject()
        Map result = new HashMap();
        result.put("serviceCode",serviceCode);
        result.put("params",params);
        return  new IomResult(result);
    }

}
